package com.lagou;


import org.junit.Before;
import org.junit.Test;
import redis.clients.jedis.HostAndPort;
import redis.clients.jedis.JedisCluster;

import java.util.HashSet;
import java.util.Set;

/**
 * Created with IntelliJ IDEA by ChouFy on 2020/8/23.
 *
 * @author chouFy
 */
public class RedisCase {
    private static JedisCluster jedisCluster = null;


    @Before
    public void before() {
        Set<HostAndPort> nodes = new HashSet<HostAndPort>();
        HostAndPort hap1 = new HostAndPort("172.16.85.20", 7001);
        HostAndPort hap2 = new HostAndPort("172.16.85.20", 7002);
        HostAndPort hap3 = new HostAndPort("172.16.85.20", 7003);
        HostAndPort hap4 = new HostAndPort("172.16.85.20", 7004);
        HostAndPort hap5 = new HostAndPort("172.16.85.20", 7005);
        HostAndPort hap6 = new HostAndPort("172.16.85.20", 7006);
        nodes.add(hap1);
        nodes.add(hap2);
        nodes.add(hap3);
        nodes.add(hap4);
        nodes.add(hap5);
        nodes.add(hap6);
        jedisCluster = new JedisCluster(nodes);
    }


    @Test
    public void get(){

        String name = jedisCluster.get("name");
        System.out.println(name);

    }

    @Test
    public void set(){
        jedisCluster.set("userid", "1");
    }

}
